package demo01;

import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.DateTimeException;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Date;

public class DateDemo02 {
    public static void main(String[] args) {

        //SimpleDateFormat
        Date date = new Date();
        System.out.println(date);

        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日   HH时mm分ss秒");

        String time1 = sdf.format(date);
        System.out.println(time1);


        //    DateTimeFormatter
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日   HH时mm分ss秒");
        LocalDateTime ld = LocalDateTime.now();
        System.out.println(ld);
        String rs = formatter.format(ld);
        System.out.println(rs);

    }
}
